home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / fractal / kaos.lha / modellib / martyd3_def.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-16  |  1.7 KB  |  85 lines

  1. /*
  2. This is a martyd3 subroutine. "martyd3" should be
  3. substituted with the proper string for a dynamical system
  4. to be installed. Define all initialization parameters
  5. here. Parameters are assigned to the default values before this program is
  6. called.
  7. */
  8. int martyd3_init()
  9. {
  10.     title_label = "Marty's D3 Map";
  11.  
  12.     mapping_on = 1;
  13.     inverse_on = 0;
  14.     fderiv_on = 0;
  15.     enable_polar = 0;
  16.     enable_period = 0;
  17.  
  18.     var_dim = 2;
  19.     param_dim = 4;
  20.     func_dim = 2;
  21.  
  22.     (void) malloc_init();
  23.  
  24.     var_label[0] = "x";
  25.     var_label[1] = "y";
  26.     param_label[0] = "alpha";
  27.     param_label[1] = "lambda";
  28.     param_label[2] = "beta";
  29.     param_label[3] = "gamma";
  30.     func_label[0] = "Modulus";
  31.     func_label[1] = "Re(Z^3)";
  32.  
  33.     param[0] = -1;
  34.     param[1] = 1.52;
  35.     param[2] = .1;
  36.     param[3] = -.8;
  37.     var_i[0] = 0.01;
  38.     var_i[1] = 0.057;
  39.  
  40.     param_min[0]= -5; param_max[0]= 5;
  41.     param_min[1]= -5; param_max[1]= 5;
  42.     param_min[2]= -5; param_max[2]= 5;
  43.     param_min[3]= -5; param_max[3]= 5;
  44.     var_min[0]= -1.5; var_max[0]= 1.5;
  45.     var_min[1]= -1.5; var_max[1]= 1.5;
  46.  
  47.     f_p = martyd3_f;
  48.     func_p = martyd3_func;
  49. }
  50. /*
  51. second user dynamical system 
  52. */
  53.     
  54. int martyd3_f(f,index,x,p,t,dim)
  55. int index,dim;
  56. double f[],x[],p[],t;
  57. {
  58.     double z2r,z2i,z3r,z3i,iv;
  59.         cmul(&z2r,&z2i,x[0],x[1],x[0],x[1]);
  60.     cmul(&z3r,&z3i,z2r,z2i,x[0],x[1]);
  61.     iv = p[0] * (x[0]*x[0] + x[1]*x[1]) + p[1] + p[2] * z3r; 
  62.     if(index ==1) {
  63.         f[0] = iv * x[0] + p[3] * z2r;
  64.         f[1] = iv * x[1] - p[3] * z2i;
  65.     }
  66. }
  67.  
  68. cmul(x,y,x1,y1,x2,y2)
  69. double *x,*y,x1,y1,x2,y2;
  70. {
  71.     *x = x1 * x2 - y1 * y2; 
  72.     *y = x1 * y2 + x2 * y1; 
  73. }
  74. /* cmul() is a subroutine local for this model */
  75. int martyd3_func(f,x,p,t,dim)
  76. double f[],x[],p[],t;
  77. int dim;
  78. {
  79.     double z2r,z2i,z3r,z3i,iv;
  80.         cmul(&z2r,&z2i,x[0],x[1],x[0],x[1]);
  81.     cmul(&z3r,&z3i,z2r,z2i,x[0],x[1]);
  82.     f[0] = x[0]*x[0] + x[1]*x[1];
  83.     f[1] = z3r;
  84. }
  85.